import request from '@/utils/request'
import {
  getToken
} from '@/utils/auth'
import {
  param
} from '@/utils/index'

// 获取用户列表
export function pageMember(member) {
  return request({
    url: '/user/member/pagingMember',
    method: 'get',
    params: member
  })
}

// 获取顾客列表
export function pagingCustomerMember(member) {
  return request({
    url: '/user/member/pagingCustomerMember',
    method: 'get',
    params: member
  })
}

// 微客 启用/禁用
export function enableDisable(member) {
  return request({
    url: '/user/member/save',
    method: 'post',
    data: member
  })
}

// 查询微客信息 详情
export function getMemberByMemberId(memberId, enterpriseId) {
  const params = {
    memberId: memberId,
    enterpriseId: enterpriseId
  }
  return request({
    url: '/user/member/getMemberByMemberId',
    method: 'get',
    params: params
  })
}

// 保存
export function saveMember(member) {
  return request({
    url: '/user/member/saveMember',
    method: 'post',
    params: member
  })
}

// 我的微客-保存
export function saveMyMember(member) {
  return request({
    url: '/user/member/saveMyMember',
    method: 'post',
    params: member
  })
}

// 批量操作
export function bacthUpdate(memberList) {
  return request({
    url: '/user/member/bacthUpdate',
    method: 'post',
    data: memberList
  })
}

// 批量操作
export function bacthUpdateAuthority(memberAuthorityList) {
  return request({
    url: '/user/member/bacthUpdateAuthority',
    method: 'post',
    data: memberAuthorityList
  })
}

// 批量设置批发商等级
export function bacthUpdateGrade(gradeEntityList) {
  return request({
    url: '/user/member/batchUpdateWholesalerGrade',
    method: 'post',
    data: gradeEntityList
  })
}

// 个人简历查询
export function getMemberResumeByMemberId(memberId) {
  return request({
    url: '/user/memberResume/gerMemberResume',
    method: 'get',
    params: {
      memberId
    }
  })
}

// 微客交易记录
export function getRecordTaskInfo(query) {
  return request({
    url: '/project/taskInfo/pagingRecordTaskInfo',
    method: 'get',
    params: query
  })
}

// 根据企业id获取企业信息
export function getMember(memberId) {
  return request({
    url: '/user/member/getMember',
    method: 'get',
    params: {
      memberId
    }
  })
}

// 统计微客订单信息
export function countMemberOrder(memberId) {
  return request({
    url: '/user/member/countMemberOrder',
    method: 'get',
    params: {
      memberId
    }
  })
}

// 我的微客
export function pagingMyMember(member) {
  return request({
    url: '/user/member/pagingMyMember',
    method: 'get',
    params: member
  })
}

// 企业微客选择器
export function pagingMemberByEnterpriseId(member) {
  return request({
    url: '/user/member/pagingMemberByEnterpriseId',
    method: 'get',
    params: member
  })
}

// 店主微客统计
export function countMyMember(member) {
  return request({
    url: '/user/member/countMyMember',
    method: 'get',
    params: member
  })
}

// 顾客微客统计
export function countCustomerMember(member) {
  return request({
    url: '/user/member/countCustomerMember',
    method: 'get',
    params: member
  })
}

// 模板下载
export function downloadErrorDate(errorCode) {
  return process.env.BASE_API + '/user/member/downloadErrorDate?' + param({
    errorCode
  }) + '&accessToken=' + getToken()
}

// 绑定子账号
export function doBindSubUser(data) {
  return request({
    url: '/user/member/doBindSubUser',
    method: 'post',
    data: data
  })
}
// 获取微客子账号信息
export function getBindSubUser(memberId) {
  return request({
    url: '/user/member/getBindSubUser',
    method: 'post',
    params: {
      memberId
    }
  })
}

// 微客备注名 修改
export function saveMemberRemark(memberRemark) {
  return request({
    url: '/user/memberRemark/save',
    method: 'post',
    data: memberRemark
  })
}

// 企业店主信息
export function pagingEnterpriseShop(query) {
  return request({
    url: '/user/member/pagingEnterpriseShop',
    method: 'get',
    params: query
  })
}

// 批量设置微客店主等级
export function saveMemberGradeBatch(memberIds, memberGradeId) {
  return request({
    url: '/user/member/saveMemberGradeBatch',
    method: 'post',
    params: {
      memberIds: memberIds,
      memberGradeId: memberGradeId
    }
  })
}

// 主播分页查询
export function pageAnchor(query) {
  return request({
    url: '/user/member/pagingAnchor',
    method: 'get',
    params: query
  })
}

// 店主业绩排名
export function pagingMemberCommission(query) {
  return request({
    url: '/user/member/pagingMemberCommission',
    method: 'get',
    params: query
  })
}

// 店主业绩统计
export function statMemberCommission(query) {
  return request({
    url: '/user/member/statMemberCommission',
    method: 'get',
    params: query
  })
}

// 后台门店设置保存信息
export function saveStoreSettingByEnterprise(data) {
  return request({
    url: '/user/member/saveStoreSettingByEnterprise',
    method: 'put',
    data: data
  })
}

export function getMemberStoreByMemberId(data) {
  return request({
    url: '/user/member/getMemberStoreByMemberId',
    method: 'get',
    params: data
  })
}

export function doSetHighestQuota(setHighestQuotaInfo) {
  return request({
    url: '/user/member/setHighestQuota',
    method: 'post',
    data: setHighestQuotaInfo
  })
}
